package com.wangwei;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class MathematicalInductionTest {

    private static final int[] rewards = {1, 5};

    static BigInteger totalForTest1 = BigInteger.ZERO;
    public static final void  test1(int total) {
        if (total == 0) {
            totalForTest1 = totalForTest1.add(BigInteger.ONE);
            return;
        } else if (total < 0) {
            return;
        } else {
            for (int i = 0; i < rewards.length; i++) {
                test1(total - rewards[i]);
            }
        }
    }

    public static final BigInteger test2(int total) {
        // 求商
        int quotient = total / 5;
        // 求余
        int remainder = total % 5;

        BigInteger result = BigInteger.ZERO;
        for (int i = quotient; i >= 0; i--) {
            result = result.add(Utils.compose(remainder + quotient + 4 * (quotient - i) , i));
        }

        return result;
    }

    public static void main(String[] args) {
        int n = 50;

        long start = System.currentTimeMillis();
//        test1(n);
        long end1 = System.currentTimeMillis();
        System.out.println(String.format("test1:: count: %s, cost: %s", totalForTest1, (end1 - start)));

        BigInteger totalForTest2 = test2(n);
        long end2 = System.currentTimeMillis();
        System.out.println(end2 - end1);
        System.out.println(String.format("test2:: count: %s, cost: %s", totalForTest2,  (end2 - end1)));
    }
}
